﻿@model BookStore.Helpers.PagedList<BookStore.Models.Book>

@{
    ViewBag.Title = "图书管理_管理员后台_第三波书店";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}
@section styles{
    <script src="~/Areas/Admin/Scripts/Book_Index.js"></script>
}

<h3 style="line-height:30px;">您现在的位置：
        @Html.ActionLink("第三波","Index","../Home")&gt;
        @Html.ActionLink("管理员后台","Index","Home")&gt;
        @Html.ActionLink("图书管理","Index","Book")
        <span style="color:red;">@TempData["message"]</span>
</h3>
<div style="width:100%;margin-bottom:20px;">
    @using (Html.BeginForm())
    { 
        <span>查询类型：</span>
        @Html.DropDownList("searchType")
        <span id="keyText">&nbsp;&nbsp;&nbsp;&nbsp;关键字：@Html.TextBox("keyword", "", new { style="width:250px;"})</span>
        <span id="keyCategory">&nbsp;&nbsp;&nbsp;&nbsp;图书类别：@Html.DropDownList("category", ViewBag.category as SelectList, new { style="width:250px;"})</span>
        <span id="keyPublisher">&nbsp;&nbsp;&nbsp;&nbsp;出版社：@Html.DropDownList("publisher", ViewBag.publisher as SelectList, new { style="width:250px;"})</span>
        <input class="btn" type="submit" value="查询" style="width:110px;"/>
        <span style="margin-left:15%;">
            @Html.ActionLink("添加图书", "Edit", "Book", null,new { style="font-size:15px;"})
        </span>
    }
</div>
<div>
    <table width="100%" style="margin-bottom:10px;">
    <tr style="font-size:16px;line-height:30px;background-color:lightsteelblue;">
        <th class="border_right" width="40%">书名</th>
        <th class="border_right" width="15%">类别</th>
        <th class="border_right" width="15%">出版社</th>
        <th class="border_right" width="20%">作者</th>
        <th width="10%">操作</th>
    </tr>
    @{
        bool flag = false;
    }
    @foreach (var book in Model)
    {
         <tr @if(flag==false){
                <text>style="font-size:14px;line-height:25px;"</text>
            }else{
                <text>style="font-size:14px;line-height:25px;background-color:lightblue;"</text>
         }>
            <td class="border">
                @Html.ActionLink(book.Title.ToMySubstring(22), "Detail", "../Book", new { id = book.Id }, new { title=book.Title})
            </td>
            <td class="border_right">
                <span title="@book.Categorie.Name">@book.Categorie.Name.ToMySubstring(8)</span>
            </td>
            <td class="border_right">
                <span title="@book.Publisher.Name">@book.Publisher.Name.ToMySubstring(7)</span>
            </td>
            <td class="border_right">
                <span title="@book.Author">@book.Author.ToMySubstring(8)</span>
            </td>
            <td class="border_right" style="text-align:center;">
                @Html.ActionLink("编辑", "Edit", "Book", new { id=book.Id},null)
                @Html.ActionLink("删除", "Delete", "Book", new { id=book.Id},new { onclick="return confirm('是否要删除这本书？');"})
            </td>
        </tr>
        flag = !flag;
    }
    </table>
</div>
@if (Model.Count>0)
{
    <div class="pager">
        <hr />
        @Html.Pager(Model)
    </div>
}
else
{
    <p>抱歉，没有找到符合要求的图书。</p>
}
